<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@taglib prefix="html" uri="http://struts.apache.org/tags-html"%>
<%@taglib prefix="logic" uri="http://struts.apache.org/tags-logic"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<bean:define id="role" value="${auth.role.roleType}" scope="session" />
<logic:equal name="role" value="admin">
	<html:form action="/flightAction">
		<h1>
			<bean:message key="flights" />
		</h1>
		<c:forEach var="flight" items="${flights}">
			<table>
				<tr>
					<td><html:radio property="flightId" value="${flight.flightId}">${flight.flightId}</html:radio></td>
				</tr>
				<tr>
					<td><bean:message key="flightCrew.name" />
						${flight.flightCrew.flightCrewName}</td>
				</tr>
				<tr>
					<td><bean:message key="plane.name" /> ${flight.plane.model}</td>
				</tr>
				<tr>
					<td><bean:message key="route" /></td>
				</tr>

				<c:forEach var="airportInRoute" items="${flight.route}">
					<tr>
						<td>${airportInRoute.airport.airportName}</td>
					</tr>
				</c:forEach>

			</table>
		</c:forEach>
		<html:errors property="chooseFlight" />
		<html:submit property="method">
			<bean:message key="flight.add" />
		</html:submit>
		<html:submit property="method">
			<bean:message key="flight.modify" />
		</html:submit>
		<html:submit property="method">
			<bean:message key="flight.delete" />
		</html:submit>
		<html:submit property="method">
			<bean:message key="flight.route" />
		</html:submit>

	</html:form>
</logic:equal>